package org.jeecg.modules.zhima.portal.task;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.zhima.portal.domain.Game;
import org.jeecg.modules.zhima.portal.service.IGameService;
import org.jeecg.modules.zhima.portal.service.IPlayerRankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class GameSchedule {

    @Autowired
    private IGameService gameService;
    @Autowired
    private IPlayerRankingService playerRankingService;

    /**
     * 积分赛计分任务
     */
    @Scheduled(fixedDelay = 1000*60)
    public void calculateGame(){
//        log.info("calculate task start");
        List<Game> gameList = gameService.calculate();
//        log.info("calculate task end count {}", gameList.size());
    }

    /**
     * 选手排名更新
     */
    @Scheduled(fixedDelay = 1000*60*10)
    public void calculateRanking(){
        playerRankingService.calculate();
//        log.info("calculate ranking task start");
//        log.info("calculate ranking task end count");
    }

}
